package service;

import java.util.ArrayList;
import java.util.List;

import beans.PersonalBean;
import beans.SalonBean;
import beans.SectorBean;
import entities.PersonalEntity;
import entities.SalonEntity;
import entities.SectorEntity;

public class SalonSrv {

	private static SalonSrv instancia = null;
		
		public static SalonSrv getInstancia() {
			if(instancia == null) {
				instancia = new SalonSrv();
			}
			return instancia;
		}

		public SalonEntity bean2Entity(SalonBean salon) {
			SalonEntity salonEntity = new SalonEntity();
			salonEntity.setId(salon.getId());
			
			List<SectorEntity> sectoresEntity = new ArrayList<SectorEntity>();
			for (SectorBean sectorBean: salon.getSectores()) {
				SectorEntity sectorEntity = SectorSrv.getInstancia().bean2Entity(sectorBean);
				sectoresEntity.add(sectorEntity);
			}
			salonEntity.setSectores(sectoresEntity);
			return salonEntity;
		}


		public SalonBean Entity2Bean(SalonEntity salon) {
			SalonBean salonBean = new SalonBean();
			salonBean.setId(salon.getId());
			
			List<SectorBean> sectoresBean = new ArrayList<SectorBean>();
			for (SectorEntity sectorEntity: salon.getSectores()) {
				SectorBean sectorBean = SectorSrv.getInstancia().entity2Bean(sectorEntity);
				sectoresBean.add(sectorBean);
			}
			salonBean.setSectores(sectoresBean);
			return salonBean;
		}
}
